class_name StaminaComponent
extends BaseComponent

#region 属性
var locked:bool = false
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init_component(args:Dictionary = {}):
	super(args)
#endregion
#region 公共方法
func set_locked(locked:bool):
	self.locked = locked
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _process(delta: float) -> void:
	if not inited:
		return
	if locked:
		return
	var max_stamina = entity.entity_data.get_attribute_value("MaxStamina",0)
	var stamina_recover_per_second = entity.entity_data.get_attribute_value("StaminaRecoverPerSecond",0)
	var attr:Attribute = entity.entity_data.find_attribute("Stamina")
	var value = stamina_recover_per_second * delta
	if value != 0:
		attr.force_set_base_value(clamp(attr.get_value() + value,0,max_stamina))
#endregion
